<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ include file="/WEB-INF/jsp/struts/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="style/home.css" type="text/css">
<link rel="stylesheet" type="text/css" media="all" href="style/alternative.css"  />
<link rel="stylesheet" type="text/css" media="all" href="script/jscalendar-1.0/calendar-win2k-cold-1.css" title="win2k-cold-1" />
<script type="text/javascript" src="script/prototype.js"></script>
<script type="text/javascript"  src="script/common.js"></script>
<script type="text/javascript" src="script/jscalendar-1.0/calendar.js"></script>
<script type="text/javascript" src="script/jscalendar-1.0/lang/calendar-zh.js"></script>
<script type="text/javascript" src="script/jscalendar-1.0/calendar-setup.js"></script>
<STYLE TYPE="text/css">
#bookTab {
	border: 2px groove #eee;
	padding-top: 1em;
}
#bookTab td{
	padding:0.2em;
	white-space:nowrap;
}
#bookTab a{
    font-size:1em;color:#330099
}
#errorDiv {
    color:red;
}
.tabTitle {
    font-size:1.3em;
    color:#330099;
    text-align:center;
}
.cellTitle {
    font-size:1em;
    color:#330099;
    text-align:right;
    padding-right:0.5em;
}
</STYLE>

</head>
<body>
<c:choose>
<c:when test="${empty book}">
<c:set var="handler" value="book.fym?method=create" />
</c:when>
<c:otherwise>
<c:set var="handler" value="book.fym?method=update" />
</c:otherwise>
</c:choose>
<div id="content">
<div id="content_inner">
<form name="bookForm" id="bookForm" action="${handler}"  method="post">
<TABLE id="bookTab" class="its" width="95%">
<thead>
<tr><th colspan="2" class="tabTitle">Book</th></tr>
  </thead>
  <TR>
    <TD width="10%"  class="cellTitle">Book SN:</TD>
    <TD>
    <input type="text" NAME="bookSN" id="bookSN" size="80" value="${book.bookSN}"/>
    </TD>
  </TR>
  <TR>
    <TD class="cellTitle">Book Name:</TD>
    <TD>
    <input type="text" NAME="bookName" id="bookName"  size="80"  value="${book.bookName}"/>
    </TD>
  </TR>
  <TR>
    <TD  class="cellTitle">Tags:</TD>
    <TD>
    <input type="text" NAME="tags" id="tags"  size="80"  value="${book.tags}"/>
    </TD>
  </TR>
  <TR>
    <TD  class="cellTitle">Book Category: </TD>
    <TD>
    <SELECT NAME="categoryID" ID="categoryID">
    <OPTION VALUE="0">无分类</OPTION>
<c:forEach items="${categories}" var="entry">
       <OPTION VALUE="${entry.key}">${entry.value.description}</OPTION>
 </c:forEach>
</SELECT>
    </TD>
  </TR>
  <TR>
    <TD  class="cellTitle">
    Borrow Information: 
    <INPUT TYPE="hidden" NAME="borrowLogID" ID="borrowLogID" value="${book.borrowLogID}">
    <INPUT TYPE="hidden" NAME="borrowerID" ID="borrowerID" value="${book.borrowerID}">
    </TD>
    <TD>
   <table>
   <TR>
    <TD align="right">Borrower</TD>
    <TD><input NAME="borrowerName" size="20" type='text' id='borrowerName' 
    value="${book.borrowerName}"/> 
    <IMG SRC="images/ico_edit.gif" BORDER="0" onclick="location.href='user.htm'"/>
    </TD>
    </TR>
   <TR>
    <TD align="right">Borrow Date</TD>
    <TD><input NAME="borrowDate" size="20" type='text' id='borrowDate' 
    value="<fmt:formatDate value='${book.borrowDate}' pattern='yyyy-MM-dd HH:mm:ss'/>"/>
    <input type='button' id='trigger1' value='...' />
    </TD>
    </TR>
       <TR>
    <TD align="right">ReturnDate</TD>
    <TD><input NAME="returnDate" size="20" type='text' id='returnDate' 
    value="<fmt:formatDate value='${book.returnDate}' pattern='yyyy-MM-dd HH:mm:ss'/>"/>
    <input type='button' id='trigger2' value='...' />
    </TD>
    </TR>
   </table>
    </TD>
  </TR>
   <TR>
    <TD colspan="2" align="center">
    <input type="hidden" name="bookID" id="bookID" value="${book.bookID}">
    <INPUT TYPE="submit" value="确认">&nbsp;&nbsp;
    <INPUT TYPE="reset" value="取消" onclick="javascript:history.back()"></TD>
  </TR>
  </TABLE>
</FORM>
<div id="errorDiv">
${errorMessage}
</div>
</div></div>
<script type="text/javascript">
    Calendar.setup({
        inputField     :    "borrowDate",      // id of the input field
        ifFormat       :    "%Y-%m-%d %H:%M:00",       // format of the input field
        showsTime      :    true,            // will display a time selector
        button         :    "trigger1",   // trigger for the calendar (button ID)
        singleClick    :    false,           // double-click mode
        step           :    1                // show all years in drop-down boxes (instead of every other year as default)
    });
    Calendar.setup({
        inputField     :    "returnDate",      // id of the input field
        ifFormat       :    "%Y-%m-%d %H:%M:00",       // format of the input field
        showsTime      :    true,            // will display a time selector
        button         :    "trigger2",   // trigger for the calendar (button ID)
        singleClick    :    false,           // double-click mode
        step           :    1                // show all years in drop-down boxes (instead of every other year as default)
    });    
</script>   

<script language="Javascript">
<c:if test="${not empty book}">
var pid = "" + "${book.categoryID}";
toSelect("categoryID",pid);
</c:if>
</script>
</body>
</html>
